home *** CD-ROM | disk | FTP | other *** search
- /*
- ** CTCPResolverCall.h
- **
- ** TurboTCP support library
- ** TCP resolver class
- **
- ** Copyright © 1993-94, FrostByte Design / Eric Scouten
- **
- */
-
-
- #pragma once
-
- #include "TCL.h"
-
- #include <Types.h> // get <ConditionalMacros.h> if available
- #if (defined(GENERATINGPOWERPC) || defined(GENERATING68K))
- #include <MacTCP.h> // Universal Headers 2.0
- #else
- #include <MacTCPCommonTypes.h> // Univ Headers 1.0 or old headers
- #include <AddressXlation.h>
- #define GENERATINGCFM USESROUTINEDESCRIPTORS
- #define Result2UPP ResultProc2UPP
- #define NewResult2Proc NewResultProc2Proc
- #endif
-
- #include "CTCPDriver.h"
- #include "CTCPEndpoint.h"
-
- #ifndef TCL_NO_TEMPLATES
- class CTCPResolverCallList;
- #else
- class CPtrArray_CTCPResolverCall;
- #define CTCPResolverCallList CPtrArray_CTCPResolverCall
- #endif
-
-
- // notification types for PostponeNotify()
-
- enum NotifType {
- notifNone,
- notifStrToAddr,
- notifAddrToName,
- notifHInfo,
- notifMXInfo
- };
-
- typedef enum NotifType NotifType;
-
-
-
- /*______________________________________________________________________
- **
- ** CTCPResolverCall
- **
- ** This class implements the core DNR calls. It is like the CTCPAsyncCall in that the call
- ** object is created to allow the call to persist beyond the scope of originating method.
- ** However, access to this object is not restricted; your application classes can and often
- ** will interact with the CTCPResolverCall object.
- **
- ** Each resolver object may support only one asynchronous resolver call at a time.
- ** You may create several resolver objects to simultaneously process several calls,
- ** so long as you respect MacTCP’s limit of 8 resolver calls open at once. The CTCPDriver
- ** acts as a referee to prohibit more than 8 simultaneous calls.
- **
- ** One set of methods (Do...) is called to initiate resolver calls. These are the methods you
- ** will typically call from your application classes. These methods initiate asynchronous
- ** calls to the DNR code resource. When the calls are completed, the notification is passed
- ** to another set of methods (Handle...). The Handle… methods return notification to your
- ** class through the Handle… methods in CTCPProtcolInterp. The exception to this is the
- ** DoAddrToStr method which returns the result immediately.
- **
- ** The userDataPtr fields of each of the calls are used by the resolver object to get
- ** notification of completion, and are not available to the caller.
- **
- ** The CTCPDriver object takes care of opening and closing the DNR code resource; it uses
- ** the OpenResolver and CloseResolver methods. You should not call these methods from your
- ** application classes.
- **
- ** The EnumCache call is not implemented in TurboTCP.
- **
- ** TurboTCP 1.0 NOTE: This class is no longer a descendant of CCollaborator. It now
- ** communicates only with the CTCPEndpoint mix-in class.
- **
- */
-
- class CTCPResolverCall TCL_AUTO_DESTRUCT_OBJECT {
-
- friend class CTCPDriver;
- friend class CTCPResolverList;
- friend class UTurboTCP;
-
- #ifdef TCL_NO_TEMPLATES
- friend class CPtrArray_CTCPResolverCall;
- #endif
-
- TCL_DECLARE_CLASS;
-
- private:
- CTCPEndpoint* itsEndpoint; // endpoint object for this resolver
- Boolean inUse; // resolver in use; can’t accept calls
- Boolean disposeOnCompletion; // dispose of resolver call once completed
- hostInfo theHostInfo; // parms for StrToAddr
- returnRec theHMXInfo; // parms for HInfo or MXInfo
- char hostName[255]; // name of user host
- NotifType pendingNotify; // resolver is in ProcessNotify queue
- static Handle macDNRcode; // the DNR code resource’s handle
- static UniversalProcPtr macDNRentry; // the DNR code entry point
- TurboTCPQElem qEntry; // completion queue entry
-
- #if GENERATINGCFM
- static ResultUPP StrToAddrUPP; // UPPs for all DNR callbacks
- static ResultUPP AddrToNameUPP;
- static Result2UPP HInfoUPP;
- static Result2UPP MXInfoUPP;
- #endif
-
-
- // constructor/destructor
-
- public:
- CTCPResolverCall(CTCPEndpoint& theEndpoint);
- private:
- virtual ~CTCPResolverCall(); // use Dispose() instead
- public:
- void Dispose();
-
-
- // initiate resolver calls
-
- void DoStrToAddr(char* theHostName);
- static void DoAddrToStr(ip_addr theIPaddr, char* theString);
- void DoAddrToName(ip_addr theIPaddr);
- void DoHInfo(char* theHostName);
- void DoMXInfo(char* theHostName);
-
-
- // respond to completion of resolver calls
-
- private:
- void ProcessNotify();
- inline void HandleStrToAddr()
- { if (itsEndpoint) itsEndpoint->HandleStrToAddr(&theHostInfo); }
- inline void HandleAddrToName()
- { if (itsEndpoint) itsEndpoint->HandleAddrToName(&theHostInfo); }
- inline void HandleHInfo()
- { if (itsEndpoint) itsEndpoint->HandleHInfo(&theHMXInfo); }
- inline void HandleMXInfo()
- { if (itsEndpoint) itsEndpoint->HandleMXInfo(&theHMXInfo); }
-
-
- // open/close TCP resolver
-
- static void OpenResolver();
- static void CloseResolver();
- static short OpenTheDNR();
- static short SearchFolderForDNRP(long targetType, long targetCreator, short vRefNum, long dirID);
- static void GetSystemFolder(short* vRefNumP, long* dirIDP);
- static void GetCPanelFolder(short* vRefNumP, long* dirIDP);
-
-
- // interrupt-level methods: delay processing for non-interrupt status
-
- void PostponeNotify(NotifType theNotifType);
- static pascal void PostponeStrToAddr(hostInfo* hostInfoPtr, char* userDataPtr);
- static pascal void PostponeAddrToName(hostInfo* hostInfoPtr, char* userDataPtr);
- static pascal void PostponeHInfo(returnRec* returnRecPtr, char* userDataPtr);
- static pascal void PostponeMXInfo(returnRec* returnRecPtr, char* userDataPtr);
-
- };
-